Copyright: TimeWalker Software 1994


Contents

Class Generator automates the often mundane task of writing the "standard" code necessary to generate a new class.  Unlike Class Wizard, Class Generator lets you generate new classes based on any class - and the resulting code is generated in your, not Microsoft's, style.

Class Generator accomplishes this by replacement.  You set up templates to be used by one or more classes. These templates contain the classes source code with place holders for the class specific information (see Creating a template for more detailed information on template writing).  Then you specify the strings to replace the place holders, and press a button.  Class Generator combines the template and the class information to create a new source and header file.

Class Generator is distributed as a fully functional application.  There are no nag screens, and no time limits after which it will stop working.  However this does not mean it is freeware.  Use it for a while and see if it meets your needs.  If so please register it ( see Registration and Support for exactly how to do this).  If not please stop using it.

The following Help Topics are available:

For Help on Help, Press F1

Using Class Generator

The Generator Tab

The Base Classes Tab

The Defaults Tab

The User Strings Tab

The Configuration Tab

Registration and Support

The System Replacement Strings


Using Class Generator

1. Make Class Generator available on the tools menu in Visual C++

Class Generator requires two pieces of information to be passed to it. The first is the project name and the second is the project directory  This is accomplished in the Visual C++ 2.0 environment by:

1. Selecting the Tools->Customize menu

2. Selecting the Tools tab on the Customize Menu

3. Pressing the Add button and put classgen.exe (with its path if necessary) in the command field of the Add Tools dialog.

4. Typing Class &Generator in for the Menu Text

4. Setting the Arguments to: $Proj $Projdir

5. Setting the Initial Directory to: $PROJDIR

6. Pressing Close

2. Create your template files

Writing a template file for Class Generator is very similar to writing the corresponding file as a C++ or header file.  The only difference is that instead of using specific class names and identifiers, you use replacement strings.  Wherever a replacement strings is found in a template, Class Generator replaces it with the "real" information when generating the new class files.  For examples of templates refer to the samples distributed with Class Generator.

3. Add the templates to Class Generator

Once the templates have been created Class Generator has to have some information about them.  This information is entered through the Base Classes Tab. Following is for the base class information for the sample templates.

Description	Default  Base Class	Header Template	Source Template	Class Specific Prompt	Add to  Class Wizard
Modal Dialog Box	CDialog	MODAL.H	MODAL.CPP	None	Yes
Modeless Dialog Box	CDialog	MODELESS.H	MODELESS.CPP	None	Yes
Window	CWnd	WND.H	WND.CPP	None	Yes
Main Dialog App	CWinApp	DLGAPP.H	DLGAPP.CPP	Main Dialog class name	Yes
3. Fill in the default information

This last step completes the information Class Generator needs to operate.  By going to the Defaults Tab and telling Class Generator the location of the templates and a few other pieces of information, you should now be ready to generate new classes!

4. Advanced Operations

Class Generator has some features which are not required in most cases, but can be useful in some situations.  One of these is the ability to define your own replaceable parameters.  This is done by through the User Strings Tab.   Another powerful feature in Class Generator is the ability to keep multiple sets of configurations.  This allows different template sets to be defined for different projects, location or people.   Configurations are set through the Configuration Tab.


The Generator Tab

This is the information needed to generate the new class files is gathered.  Click on the area where you want help.


The Base Classes Tab

This is where base class category information is maintained.  A base class category contains a description of the category, a default base class for the category, the template files,  and whether or not the class should be made visible to the Class Wizard.  Click on the picture below in the area where you want help.


Adding or Changing Base Class Categories

New base class category information is added, or existing  information is changed on the following screen  Click on the picture below in the area where you want help


The Defaults Tab

This is where Class Generator defaults are set.  Click on the picture below in the area where you want help


The User Strings Tab

Replaceable Strings come in three forms.  The predefined system replacement strings, User defined replaceable strings and project specific replaceable strings.   User defined replacement strings are added, deleted or modified here.  Click on the picture below in the area where you want help

An example of where user defined replacement strings may be useful is when multiple people are using the same templates, and each user wants a different string, such as a job title,  placed in the file

Be careful when creating user strings.  The user strings are case sensitive and replaced in the template in the same order as they appear in the listbox.  First the predefined system strings are replaced.  Then the project specific strings are processed, and last the user defined Strings.  Thus if your list contains:

Replace	With

$_USER	YOUR

$_USER1	MY

$_DateOfBirth	11/11/11

and the template contains

$_USER1 birthday and $_USER birthday are on $_DateOfBirth

after the replacements you will have (assuming you create the class on 3/19/94)

MY1 birthday and MY birthday are on 3/19/94OfBirth

instead of the expected

YOUR birthday and MY birthday are on 11/11/11

This is because the $_USER part of  $_USER1 is replaced before it process $_USER1, and the built in replacement string $_Date part of $_DateOfBirth is replaced before any user strings are processed.

This behavior can be used to your advantage.  For example if you have defined the strings as shown above , and put replacement string $_$_LocationAddress in your template you can switch between addresses by simply changing the $_Location user string from Home to Work.  This technique allows a number of replacement string to be changed by changing a single controlling replacement string.


The Configuration Tab

A configuration is a set of Class Generator information. This includes all of the information available on the Base Classes, Default, and User Strings tabs. By setting up different configurations, one has the ability to quickly switch between  sets of templates, company, and user information.   Configurations can be defined for different projects, locations, or anything else you find useful. Click on the picture below in the area where you want help


Project Specific Replacement Strings

If you need replacement strings which vary based on the project , this is accomplished through the project string file.  The file is an ASCII file must be in the project directory and which contains the user strings in the following format:

ReplaceThis <white space> WithThis

where ReplaceThis is the string which is to be replaced (i.e. the replaceable string), <white space is any number of spaces or tabs, and WithThis is what the replacement string is to be changed into.  The name of the project file is specified in the Defaults Tab.


Adding or Changing User Replacement Strings

The strings are added or changed via the following screen.  Click on the picture below in the area where you want help


Registration and Support

How To Register

The Generator applications can be registered one of two ways.  The first is to send the registration fee to:

TimeWalker Software

7111 Tyler Street

Hudsonville MI 49426

The second way to register is electronically on CompuServe.  This can be done by going to the SWREG forum and ....

Pricing:

The license fee for an individual copy of Class Generator and Clipboard Generator is $25.00.  This entitles the registered user to use Class Generator on as many PC's as he/she/it wants.  Please contact the author for information on site or network licenses.

Support

If you have suggestions or questions you can get technical support through the above address or at

CIS: 72010,3260

Internet: 72010,3260@CIS.COM


The Replaceable Parameters
The System Replacement Strings

$_Filename	The name of the file being created.

$_BaseFile	The file name minus the extension

$_HeaderFile	The name of the header file being generated

$_SourceFile	The file name of the implementation file being generated

$_ClassName	The name of the class being generated

$_BaseClass	The base class for the class being created

$_UserID	The value set up for the user ID in Defaults tab dialog

$_CompanyName	The value set up for the company name in Defaults tab dialog

$_Date	The date the file was generated

$_Month	The month the file was generated (1-12)

$_Day	The day the file was generated (in decimal form)

$_Year	The year the file was generated

$_Description	The class description given on the Generator tab dialog

$_ProjectDir	The current project directory

$_Project	The current project name

$_ResourceID	The resource ID specified in on the Generator tab dialog

$_ClassSpecific	The class specific information from the Generator tab dialog

+ Any project defined replacement string

+ Any user defined replacement strings


Tabs
Clicking on the tab activates that option dialog.


Class Name
This is the name of the new class.  Whatever is entered here will replace the replacement string $_ClassName in the templates.  This field must be filled for a class to be generated.


Class Specific String
This specifies the information to replace the replacement string $_ClassSpecific in the templates.  In many cases no class specific string will be needed.  The label for this filed may change as different base calss categories are chosen.  To aid in using this string, a custom prompt for each category can be specified via the Base Classes tab dialog.


Header File
This is the name of the header file which will be created by Class Generator.  Whatever is entered here will also replace the replacement string $_Filename in the header file template.


Implementation File
This is the name of the source code file which will be created by Class Generator.  Whatever is entered here will also replace the replacement string $_Filename in the implementation file template.


Base Class Description
This indicates which template should be used when creating the class files, and selects a default base class.  This default cab be changed by selecting another class in the Base class field.


Base Class Name
If the class being created is to be derived from a base class, this field specifies the name of the base class.  The items in the selection list come from two sources.   First,  any classes you have added through the Base Classes Configuration.  Second, any classes in the projects Class Wizard information.  If the necessary base class is not supplied by either of these sources, simply type in the name of the base class you want.   Whatever is entered here will replace the replacement string $_BaseClass in the file templates.


Resource
This field is used for classes which require resources, such as CDialog derived classes.  The resources are available in the list the same as is available in Class Wizard. Whatever is entered here will replace the replacement string $_ResourceID in the templates.


Class Description
The class description allows you to create templates where the purpose or some other aspect of the class can be commented.  Whatever is entered here will also replace the replacement string $_Description in the templates.


Add to Class Wizard
If this box is checked, the class will be added to the projects Class Wizard information.  Since Class Wizard is limited in the types of classes it understands, this button should only be checked in the cases where the new class has in its base class tree a class supported by Class Wizard.  If a Class Wizard file with the same name as the current project cannot be found in the current project directory, this button will be disabled.


OK
Accepts and saves all the information on all on the tabbed options dialogs and ends Class Generator.


Cancel/Close
Exits Class Generator without saving any information.  This will read Cancel if no information has been saved.  If any information has been changes and saved by pressing Apply Now, the button will read Close.


Apply Now
Saves the information of the currently selected tab option dialog.  It does not save the information for every tab option and does not end Class Generator.


Help
Brings up this help file for the currently active tab option.


Add Class
Click on this to create a new base class category.  This will bring up the Base Class Category dialog which will is where the necessary information is entered.


Change Class
Click on this to change the information for a base class category.  This will bring up the Base Class Category dialog which will is where the necessary information is changed.


Delete Class
Removes a base class category.


Class List
This is a list of the current base class categories.  The list can be changed using the Add Class, Change or Delete buttons.


Add Deccription
This is the name for the Base class category which will be shown on the generator dialog and in the Base Class list box.  It should describe what the base class in the template is or does.


Add Base Class Name
This is the default base class name which will be selected when the category is chosen.


Add Header Template
This is the name of the template file to be used when creating the header file for the new class.  It is not necessary to specify the file path here since the path is set in the defaults tab option dialog.


Add Source Template
This is the name of the template file to be used when creating the implementation file for the new class.  It is not necessary to specify the file path here since the path is set in the defaults tab option dialog.


Class Specific Prompt
This will become the label text for the class specific field on the Generator tab dialog whenever the base class category is selected.  It is used to tell the user of the base class what the class specific string is supposed to contain.  For example in a CWinApp derived class the class specific string might contain the name of the main window class, and so this fiels woutl read (without the quotes) Main Window Class Name.


Add Browse
Click on this button to select the file from a list if you cannot remember its name.


Generic OK
Press this to accept and save the information entered in the dialog box.


Generic Cancel
Press here to end the dialog box without saving any changes.


UserID
This is the string which will replace the $_UserID string in the file templates.


Company Name
This is the string which will replace the $_CompanyName in the file templates.


Template Search Path
Class Generator will search this path for the implementation files.  Directory names should be separated by semicolons.  e.g. C:\TEMPLATE;D:TEMPLATE.


Replace Holder
This is the place holder you have entered in your templates which you want replaced by something else.


Replace String
This is what you want to replace the place holders you have entered into your templates.


Replace List
This is a list of the currently available user defined replacement strings.


Add String
Click on this to create a User Replacement string .  This will bring up the Replacement String  dialog which will is where the necessary information is entered.


Change String
Click on this to change an existing User Replacement string .  This will bring up the Replacement String  dialog which will is where the necessary information is changed.


Delete String
Clicking this will remove the currently selection from the list of User Replacement strings.


Move Up
Move the currently selected sting up in the list so it is substituted before another string.


Move Down
Move the currently selected sting down in the list so it is substituted after another string.


Project Strings File Name
This specifies the name of the project strings file.  See Project Specific Replacement Strings for details on the format and location of the file.  The name can be a any valid file name, or you can use the $_Project replacement string in a file name template if you wish to have the Class Generator create a name file name based on the current project (e.g. if you have two projects, FOO and BAR, $_Project.STR will have Class Generator look for the file FOO.STR when FOO is the current project, and BAR.STR when BAR is the project.)


Configuration Selector
This box lists all of the available configurations.  If no configurations have been added, then only the Default configuration will appear.  Configurations are added or removed through the Configuration Tab.


Add Config
Press this button to add a new configuration to Class Generator.  Once the configuration has been added, and the OK or Apply Now button pressed, the new configuration will be available.  It will be necessary to add the necessary template and default information to the new configuration the first time it is used.


Delete Config
Pressing this button deletes a configuration from Class Generator.  To allow you to remove the category from Class Generator without losing all related information, Class Generator does not remove the information from the Registry.  This gives the ability to re-enter the category name later and undelete the information.  If you wish to remove all traces of the configuration, and thus the undelete ability, you will have to do it manually with the registry editor.  An entire project can be deleted from the registry by deleting the entry HKEY_CURRENT_USER\Software\TimeWalker Software\Class Generator\Configuration Name.


Config List
This lists all of the configuration of which Class Generator is currently aware.